﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.IO;

namespace DVRMS_Renamer
{
    public enum AutoActions
    {
        AutoNone = 0,
        AutoSummary = 1,
        AutoSilent = 2
    }
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        [PreEmptive.Attributes.Setup(CustomEndpoint = "so-s.info/PreEmptive.Web.Services.Messaging/MessagingServiceV2.asmx")]
        [PreEmptive.Attributes.Teardown()]
        static void Main(string[] args)
        {
            string FolderToScan = "";
            string FolderToCompare = "";
            AutoActions AutoAction = AutoActions.AutoNone;

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            foreach (string s in args)
            {
                if (s.Substring(0, 8).ToLower() == "/source=")
                {
                    FolderToScan = Path.GetFullPath(s.Substring(8));
                }
                if (s.Substring(0, 12).ToLower() == "/duplicates=")
                {
                    FolderToCompare = Path.GetFullPath(s.Substring(12));
                }

                // TODO:DS Handle actions of:
                //  AutoSummary - auto process through to the summary screen
                //  AutoSilent - show no interface
                if (s.Substring(0, 8).ToLower() == "/action=")
                {
                    switch (s.Substring(8))
                    {
                        case "AutoSummary":
                            AutoAction = AutoActions.AutoSummary;
                            break;
                        case "AutoSilent":
                            AutoAction = AutoActions.AutoSilent;
                            break;
                    }
                }
            }

            Application.Run(new frmMain(FolderToScan, FolderToCompare, AutoAction));
        }
    }
}
